<template>
  <div class="aui-card-list">
    <uni-list-query-card :queryShow="queryShow" @query-click="getDataList()" @click="(e)=>{this.queryShow=e}" @searchReset="searchReset()">
      <!--文本框-->
      <el-col :span="6">
        <el-form-item label="接口编码">
          <el-input v-model="dataForm.apiCode" placeholder="接口编码" clearable></el-input>
        </el-form-item>
      </el-col>
      <!--文本框-->
      <el-col :span="6">
        <el-form-item label="业务主键">
          <el-input v-model="dataForm.bizId" placeholder="业务主键" clearable></el-input>
        </el-form-item>
      </el-col>
      <!--文本框-->
      <el-col :span="6">
        <el-form-item label="接口发送状态">
          <el-input v-model="dataForm.sendStatus" placeholder="接口发送状态 0-未发送 1-发送中 2-发送成功 3-发送失败" clearable></el-input>
        </el-form-item>
      </el-col>
      <!--文本框-->
      <el-col :span="6">
        <el-form-item label="回写状态">
          <el-input v-model="dataForm.feedbackStatus" placeholder="回写状态 0-未回写 1-回写中 2-回写成功 3-回写失败" clearable>
          </el-input>
        </el-form-item>
      </el-col>
    </uni-list-query-card>
    <el-card shadow="never" class="aui-card-list-body">
      <vxe-toolbar setting>
        <template v-slot:buttons>
          <el-button v-if="$hasPermission('api:apiNotifyInfo:save')" type="primary" @click="addOrUpdateHandle()">
            {{ $t('add') }}
          </el-button>
          <el-button v-if="$hasPermission('api:apiNotifyInfo:delete')" type="danger" @click="deleteHandle()">
            {{ $t('deleteBatch') }}
          </el-button>
        </template>
        <template v-slot:tools>
          <el-button icon="el-icon-refresh" @click="getDataList()" circle></el-button>
          <!-- <el-button icon="el-icon-download" @click="$refs.xTable.openExport()" circle></el-button> -->
        </template>
      </vxe-toolbar>
      <vxe-table ref="xTable" :loading="dataListLoading" class="vxe-table-element" auto-resize :data="dataList">
        <vxe-table-column type="index" align="center" fixed="left" width="60"></vxe-table-column>
        <vxe-table-column field="bizId" fixed="left" title="业务主键">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row)">{{scope.row.bizId}}</el-button>
          </template>
        </vxe-table-column>
        <vxe-table-column field="apiCode" title="接口编码" width="120">
        </vxe-table-column>
        <vxe-table-column field="apiName" title="接口名称">
        </vxe-table-column>
        <vxe-table-column field="sendStatus" title="接口发送状态" width="100">
          <template slot-scope="scope">
            {{$getDictLabel('API_SEND_STATUS', scope.row.sendStatus)}}
          </template>
        </vxe-table-column>
        <vxe-table-column field="sendTime" title="接口发送时间" width="160">
        </vxe-table-column>
        <vxe-table-column field="feedbackStatus" title="回写状态" width="100">
          <template slot-scope="scope">
            {{$getDictLabel('API_FEEDBACK_STATUS', scope.row.feedbackStatus)}}
          </template>
        </vxe-table-column>
        <vxe-table-column field="feedbackTime" title="回写时间" width="160">
        </vxe-table-column>
        <vxe-table-column field="createDate" title="创建时间" width="160">
        </vxe-table-column>
      </vxe-table>
      <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
                     layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
                     @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </el-card>
  </div>
</template>
<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './apiNotifyInfo-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      searchShow: true,
      mixinViewModuleOptions: {
        getDataListURL: '/api/apiNotifyInfo/page',
        getDataListIsPage: true,
        deleteURL: '/api/apiNotifyInfo',
        deleteIsBatch: true,
        exportURL: '/api/apiNotifyInfo/export'
      },
      dataForm: {
        interfaceNo: '',
        bizId: '',
        sendStatus: '',
        feedbackStatus: ''
      }
    }
  },
  components: {
    AddOrUpdate
  },
  methods: {
    // 新增 / 修改
    addOrUpdateHandle (row) {
      let id
      if (row) {
        id = row.id
      }
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.addOrUpdate.dataForm.id = id
        this.$refs.addOrUpdate.init()
      })
    }
  }
}
</script>
